'use strict';
module.exports = {
    async multipartToJson() {
        const body = {};
        try {
            const parts = this.multipart();
            let part = null;
            while ((part = await parts()) != null) {
                if (part.length) {
                    body[part[0]] = part[1];
                }
            }
            if (Object.keys(body).length > 0) {
                return body;
            }
            return null;
        } catch {
            return null;
        }
    },
};